<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_firmlist" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="staffEmploymentSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/oa/humanresources/InterviewAdoptList?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 员工基本信息 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="公司" prop="firm_name">
              {{s_firmlist.firm_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="部门" prop="d_firm_name">
              {{s_firmlist.d_firm_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="岗位" prop="role_id">
              <el-select style='width:100%' v-model="s_firmlist.role_id">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_role" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="姓名" prop="person_name">
              {{s_firmlist.person_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="照片" prop="">
              <input type=file />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 登陆信息 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="用户登陆账号" prop="username">
              <span class="input-icon input-icon-right">
                <input type="text" class="form-control" id="username" name="username" value='{{mvc:isNull(param['username'],'')}}' placeholder='最多10个字符'>
                <i class="ace-icon fa fa-user"></i></span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="用户登陆密码" prop="password">
              <el-input type="password" v-model="ts_account.password" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="重复密码" prop="J_password">
              <el-input type="password" v-model="ts_account.J_password" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="领导人" prop="user_parent">
              <el-select style='width:100%' v-model="ts_account.user_parent">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_access" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="staffEmploymentSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/oa/humanresources/InterviewAdoptList?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'StaffEmployment',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_firmlist: {
          firm_name: null,
          d_firm_name: null,
          role_id: null,
          person_name: null,
        },
        ts_account: {
          username: null,
          password: null,
          J_password: null,
          user_parent: null,
        },
        s_role: [],
        s_access: [],
        loading: false,
        rules: {
          role_id: [{
            required: true,
            message: "岗位不能为空",
            trigger: 'blur',
          }],
          username: [{
            required: true,
            message: "用户登陆账号不能为空",
            trigger: 'blur',
          }],
          user_parent: [{
            required: true,
            message: "领导人不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/humanresources/EmployeeAction/staffEmployment?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      staffEmploymentSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/oa/humanresources/EmployeeAction/staffEmploymentSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/oa/humanresources/StaffList/staffList?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
